<!doctype html>
<html>
<head>
<meta charset=utf-8"utf-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, minimal-ui" />
<meta name="format-detection" content="telephone=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>忘记密码</title>
<script type="text/javascript" src="../js/public/zepto.js" tppabs="http://h5.9188.com/js/public/zepto.js"></script>
<style type="text/css">
body{ background:#f7f7f7; min-width:320px; font-size:14px; font-family:arial,Microsoft YaHei, Helvetica, sans-serif; color:#222; tap-highlight-color:rgba(0,0,0,0); -webkit-tap-highlight-color:rgba(0,0,0,0); -moz-tap-highlight-color:rgba(0,0,0,0)}
html,body,button,input,select,textarea,figure,h1,h2,h3,h4,h5,ul,li,dl,dt,dd,p,span{ margin:0; padding:0}
@media screen and (min-width:480px){html,body,button,input,select,textarea{font-size:18px}}
@media screen and (min-width:640px){html,body,button,input,select,textarea{font-size:24px}}
ol, ul, li,input{ list-style:none}
i,o,cite,em{ font-style:normal}
p{ line-height:1.2rem}
a{ color:#333; text-decoration:none}
input{ outline:none; -webkit-tap-highlight-color:rgba(255,255,255,0); -webkit-appearance:none; font-family:"微软雅黑"}
input::-webkit-input-placeholder,input::-moz-placeholder{ color:#d0d0d0}
.clearfix{ overflow:hidden; zoom:1}
.left{ float:left}
.right{ float:right}
.gray{ color:#8e8e8e}
.fixed2{ position:fixed; top:0; left:0; z-index:9; width:100%}
.pdLfrt09{ padding:.1rem .9rem 0 .9rem}
.pdTop06{ padding-top:.6rem}
.pdTop08{ padding-top:.8rem}
.mgTop2{ margin-top:2rem}
.tzHeader{ position:relative; padding-bottom:2.7rem; z-index:10}
.tzHeader h1{ width:11rem; margin:0 auto; text-align:center; font-size:1.1rem; color:#fff}
.fcHeader{ width:100%; height:2rem; padding-top:.7rem; background:#db150b; border-bottom:1px solid #d5d5d5}
.fcbackIco2{ position:absolute; top:.9rem; left:1.1rem; color:#fff; display:inline-block; width:.7rem; height:.65rem; border-left:.2rem solid #fff; border-bottom:.2rem solid #fff; transform:rotate(-315deg); -webkit-transform:rotate(-315deg); -moz-transform:rotate(-315deg)}
.s1{ line-height:2.5rem; background:#fff; margin-top:.7rem; overflow:hidden; zoom:1}
.s1 span{ float:left; width:26%; margin-right:1%; text-align:center; color:#222; font-size:.93rem}
.s1 input{ width:73%; border:none;height:1.3rem; line-height:1.3rem; margin-top:.7rem; font-size:.92rem}
.payment{ display:block; line-height:2.5rem; text-align:center; letter-spacing:.1rem; margin-top:.8rem; color:#fff; font-size:1.1rem; background:#f26c60; border-radius:.2rem; -webkit-border-radius:.2rem; -moz-border-radius:.2rem}
.payment:active{ color:#fff}
.payment2{ margin-top:3rem}
.admi{ float:left; width:1.06rem; height:1.25rem; margin:.6rem .8rem 0 .8rem; background:url("../img/admi.png")/*tpa=http://h5.9188.com/img/admi.png*//*tpa=http://h5.9188.com/img/admi.png*/ no-repeat center; background-size:1.06rem 1.25rem; -webkit-background-size:1.06rem 1.25rem; -moz-background-size:1.06rem 1.25rem}
.captcha{ float:left; width:1.25rem; height:.34rem; margin:1.1rem .9rem 0 .8rem; background:url("../img/account/captcha.png")/*tpa=http://h5.9188.com/img/account/captcha.png*//*tpa=http://h5.9188.com/img/account/captcha.png*/ no-repeat center; background-size:1.25rem .34rem; -webkit-background-size:1.25rem .34rem; -moz-background-size:1rem 1.3rem}
.phone{ float:left; width:.78rem; height:1.3rem; margin:.6rem .9rem 0 .8rem; background:url("../img/account/phone.png")/*tpa=http://h5.9188.com/img/account/phone.png*//*tpa=http://h5.9188.com/img/account/phone.png*/ no-repeat center; background-size:.78rem 1.3rem; -webkit-background-size:.78rem 1.3rem; -moz-background-size:.78rem 1.3rem}
.loginBtn,.register{ display:block; width:46%; text-align:center; margin-top:1rem; line-height:2.6rem; color:#fff; background:#f26c60; font-size:1rem; border-radius:.2rem; -webkit-border-radius:.2rem; -moz-border-radius:.2rem}
.register{ background:#bfbfbf}
.loginBtn:active,.register:active{ text-decoration:none; color:#fff}
.yzmpic{ position:absolute; width:2.5rem; height:.83rem; right:.4rem;}

/*msg弹窗*/
@-webkit-keyframes boxfade{0%{opacity:0;}20%{opacity:0.8;}80%{opacity:0.8;}100%{opacity:0;}}
@-o-keyframes boxfade{0%{opacity:0;}20%{opacity:0.8;}80%{opacity:0.8;}100%{opacity:0;}}
@-ms-keyframes boxfade{0%{opacity:0;}20%{opacity:0.8;}80%{opacity:0.8;}100%{opacity:0;}}
.alertBox{font-size:15px;text-align: center;border-radius:5px;position: fixed;left:50%;top:50%;margin:-20px 0 0 -150px;background:#000;color:#fff;width:300px;height:40px;line-height:40px;-webkit-animation:boxfade 2s ease;-ms-animation:boxfade 2s ease;-o-animation:boxfade 2s ease; z-index:10001}
/*遮罩层*/
.mask{background:#000;opacity:0.4;width:100%;height:150%;position:fixed;z-index:9999;left:0;top:0; display: none;}
</style>
<body>
	<article class="gray">
		<header class="tzHeader">
		<div class="fixed2">
			<section class="fcHeader">
				<h1>忘记密码</h1>
				<a href="javascript:history.go(-1);" class="fcbackIco2"></a>
			</section>
		</div>
		</header>
		<div class="pdLfrt09" id="forgotpass1">
			<div class="s1">
				<em class="admi"></em><input id="username" type="text"
					placeholder="请输入用户名">
			</div>
			<a href="javascript:;" class="payment payment2" id="btn_tj">下一步</a>
		</div>
		<div class="pdLfrt09" style="display: none" id="forgotpass2">
			<div class="s1">
				<em class="phone"></em><input type="text" placeholder="请输入您绑定的手机号码"
					id="mobile">
			</div>
			<div class="s1">
				<em class="phone"></em><input type="tel" placeholder="请输入右侧四位数字" id="yzmpic"><strong class="yzmpic"><img src="../img.jo.jpg" tppabs="http://h5.9188.com/img.jo" width="100%"></strong>
			</div>
			<p class="pdTop06">为了验证您的身份，我们给您已绑定的手机号发送短信验证码</p>
			<a href="javascript:;" class="payment payment2" id="btn_tj2">下一步</a>
		</div>
		<div class="pdLfrt09" style="display: none" id="forgotpass3">
			<div class="s1">
				<em class="captcha"></em><input type="text"
					placeholder="请输入手机收到的验证码" id="yzm">
			</div>
			<p class="gray pdTop08">短信收取大约60秒，如果没有收到验证码，可以重新发送，以最后一个验证码为准。</p>
			<div class="clearfix mgTop2">
				<a href="javascript:;" class="left loginBtn" id="tjyzm">提交</a><input
					name="重新发送" type="submit" id="resend" value="重新发送(60秒)"
					class="right register" style="border: none">
			</div>
		</div>
	</article>
	<div class="mask" style='display:none;' id='mask'></div>
<script>
//公用弹出层和加载层
var win_alert = alert;
window['alert'] = function (msg, loading) {
	if (!loading) {
		clearTimeout(window.alert.time);
		var obj = $('<div class="alertBox">' + msg + '</div>');
		$('body').append(obj);
		window.alert.time = setTimeout(function () {
			$(".alertBox").remove();
		}, 2000);
	} else {
		$('body').append($('<div class="alertBox"><div class="box_loading"><div class="loading_mask"></div></div>' + msg + '</div>'));
		$('.alertBox').css({"webkitAnimationName": "boxfade_loading", "opacity": 0.8});
		$('#mask').show();
	}
};

var remove_alert = function () {
	$('.alertBox').remove();
	$('#mask').hide();
};
$(function () {
	var wait=60;
	var name = localStorage.getItem("username") || '';
	$("#username").val(name);
	//检查用户名是否存在
	$("#btn_tj").click(function(){
		if($("#username").val()==""){
			alert("请输入用户名");
			return
		}
		checkUserForm();
	});
	//发送验证码
	$("#btn_tj2").click(function(){
		if(!$("#mobile").val()){//输入号码为空时，不予验证
			alert("请输入有效手机号码");
			return false;
		}
		var data ="uid="+ encodeURIComponent($("#username").val())+"&mobileNo="+ encodeURIComponent($("#mobile").val())+"&mtype=4";
		$.ajax({
			url : "http://h5.9188.com/user/forgetpwd.go",
			type : "POST",
			dataType : "xml",
			data : data,
			success : function(xml) {
				var R = $(xml).find("Resp");
				var code = R.attr("code");
				if (code == "0") {
					getyzmCode();
				}else{
					alert("手机号码不匹配,请检查是否正确");
				}
			}
		});
	});
	
	$(".yzmpic").on("click",function(){
		$(this).find("img").attr("src","/img.jo?"+Math.random())
	})
	
	
	var pass;
	//获取验证码方法
	function getyzmCode(){
		//var data ="uid=" + encodeURIComponent($("#username").val())+"&flag=1";
		var get_yzm_data={
			uid:encodeURIComponent($("#username").val()),//用户名
			flag:"1",//标示
			yzm:$("#yzmpic").val(),
			hztype:"0",//是否需要检测图片验证码
			mtype:"4"//请求来源终端
		};
		$.ajax({
			url : "http://h5.9188.com/user/usergetpwd.go",
			type : "POST",
			dataType : "xml",
			//data : data,
			data : get_yzm_data,
			success : function(xml) {
				var R = $(xml).find("Resp");
				var r = R.find("row");
				var code = R.attr("code");
				var desc = R.attr("desc");
				pass = r.attr("pass");
				if (code == "0") {
					if(document.getElementById('forgotpass3').style.display == 'none'){
						countDown();
					}
					$("#forgotpass3").show().siblings("div").hide();
				} else if(code=="1005"){
					alert("对不起，您的忘记密码请求次数已超过每天限制次数(3次)！")
				}else{
					alert(desc);
				}
			},
		});
	}
	//提交验证码获取密码
	$("#tjyzm").click(function(){
		var data ="uid=" + encodeURIComponent($("#username").val())+"&flag=1&yzm=" + $("#yzm").val()+"&mtype=4";
		$.ajax({
			url : "http://h5.9188.com/user/usergetpwdyz.go",
			type : "POST",
			dataType : "xml",
			data : data,
			success : function(xml) {
				var R = $(xml).find("Resp");
				var r = $(R).find("row");
				var code = R.attr("code");
				var desc = R.attr("desc");
				pass = r.attr("pass");
				if (code == "0") {
					alert('您的新密码为:'+pass, 'load');
					$('#mask').click(function (){
						$.ajax({
							url:'http://h5.9188.com/user/mchklogin.go',
							type:'GET',
							success:function(xml){
								var R = $(xml).find('Resp');
								var c = r.attr('code');
								if(c == '10001'){
									window.location.href = 'cpwd.html-pass=.htm'/*tpa=http://h5.9188.com/alone/cpwd.html?pass=*/+pass;
								}else{
									window.location.href = 'login.html'/*tpa=http://h5.9188.com/alone/login.html*/;
								}
							}
						});
					});
				} else {
					alert(desc);
				}
			}
		});
	});
	//检查用户名是否存在
	function checkUserForm(){
		if($('#username').val()){
			var data ="uid=" + encodeURIComponent($("#username").val())+"&mtype=4";
			$.ajax({
				url : "http://h5.9188.com/user/checkexist.go",
				type : "POST",
				dataType : "xml",
				data : data,
				success : function(xml) {
					var R = $(xml).find("Resp");
					var code = R.attr("code");
					var desc = R.attr("desc");
					if (code == "1") {//用户名存在
							showStep2();
					}else{
						alert("您的用户名不存在");
					}	
				}
			});
		}
	}
	function showStep2(){
		$("#forgotpass2").show();
		$("#forgotpass2").siblings("div").hide();
	}
	//重新发送
	$("#resend").bind("click",function(){
		countDown();
	});
	function countDown(){
		if(wait == 0){
			$("#resend").attr("disabled",false);			
			$("#resend").val("重新发送");
			wait = 60;
		}else{
			$("#resend").attr("disabled", true);
			$("#resend").val("重新发送(" + wait + ")");
			wait--;
			setTimeout(function() {
				countDown();
			}, 1000);
		}
	}
	//重新发送验证码
	function zeroDownAjax(){
		var data ="uid=" + encodeURIComponent($("#username").val())+"&flag=1"+"&mtype=4";
		$.ajax({
			url : "http://h5.9188.com/user/usergetpwd.go",
			dataType : "xml",
			data:data,
			success : function(xml) {
				var R = $(xml).find("Resp");
				var desc = $(R).attr("desc");
				alert(desc);
			}
		});
	}
});
</script>
</body>
</html>